<%@ page import="com.hkw.model.Student" %><%--
  Created by IntelliJ IDEA.
  User: 12244
  Date: 2020/8/31
  Time: 14:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>学生信息修改</title>
    <link rel="stylesheet" href="./css/bootstrap.min.css">
</head>
<body>
<%--表单回显相应学生的相关信息--%>
<form action="update" method="post" onsubmit="return check()">
    <div class="form-group" hidden="hidden">
        <label for="id1">编号</label>
        <input type="text" class="form-control" id="id1" name="id" value="<%=((Student)request.getAttribute("student")).getId()%>">
    </div>
    <div class="form-group">
        <label for="name1">姓名</label>
        <input type="text" class="form-control" id="name1" name="stname" value="<%=((Student)request.getAttribute("student")).getName()%>">
    </div>
    <div class="form-group">
        <label>性别</label>
        <%-- 判断回显的是男是女，然后相应标签加上checked属性 --%>
        <%
            if(((Student)request.getAttribute("student")).getSex().equals("男")){
        %>
        <input type="radio" class="radio-inline"  name="sex" value="男" id="sex1" checked="checked">男
        <input type="radio" class="radio-inline" name="sex" value="女" id="sex2">女
        <%
            }else{
        %>
        <input type="radio" class="radio-inline"  name="sex" value="男" id="sex1">男
        <input type="radio" class="radio-inline" name="sex" value="女" id="sex2" checked="checked">女
        <%
            }
        %>
    </div>
    <div class="form-group">
        <label for="date1">出生日期</label>
        <input type="date" id="date1" name="birthday" value="<%=((Student)request.getAttribute("student")).getBirthday()%>">
    </div>
    <div class="form-group">
        <label for="email1">邮箱</label>
        <input type="email" class="form-control" id="email1"  name="email" value="<%=((Student)request.getAttribute("student")).getEmail()%>">
    </div>
    <div class="form-group">
        <label for="remark1">备注</label>
        <input type="text" class="form-control" id="remark1" name="remark" value="<%=((Student)request.getAttribute("student")).getRemark()%>">
    </div>
    <button type="submit" class="btn btn-default" id="updateStudent">修改</button>
</form>
</body>
<script src="./js/jquery-3.3.1.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
<script>
    //校验方法
    function check(){
        if($("#name1").val()==null||$("#name1").val().trim()==""){
            alert("姓名不能为空!");
            return false;
        }else if($("#sex1:checked").val()!="男"&&$("#sex2:checked").val()!="女"){
            alert("性别不能为空!");
            return false;
        }else if($("#date1").val()==null||$("#date1").val().trim()==""){
            alert("生日不能为空!");
            return false;
        }else if($("#email1").val()==null||$("#email1").val().trim()==""){
            alert("邮箱不能为空!");
            return false;
        }else if($("#remark1").val()==null||$("#remark1").val().trim()==""){
            alert("备注不能为空!");
            return false;
        }
        return true;
    }
</script>
</html>
